//-----------------------------------------------------------------------------
// luna2d engine
// Copyright 2014-2017 Stepan Prokofjev
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------

#pragma once

#include "lunaengine.h"
#include "lunastringenum.h"
#include "lunaresolutions.h"
#include <json11.hpp>

namespace luna2d{

enum class LUNAOrientation
{
	PORTRAIT,
	LANDSCAPE
};

const LUNAStringEnum<LUNAOrientation> ORIENTATION =
{
	"portrait",
	"landscape"
};

enum class LUNAScaleMode
{
	STRETCH_BY_WIDTH,
	STRETCH_BY_HEIGHT,
	FIT_TO_WIDTH,
	FIT_TO_HEIGHT,
	MIN_WIDTH,
	MIN_HEIGHT,
};

const LUNAStringEnum<LUNAScaleMode> SCALE_MODE =
{
	"stretchByWidth",
	"stretchByHeight",
	"fitToWidth",
	"fitToHeight",
	"minWidth",
	"minHeight",
};

class LUNAConfig
{
public:
	std::string gameName;
	LUNAOrientation orientation = LUNAOrientation::LANDSCAPE;
	std::vector<std::string> resolutions = { DEFAULT_RESOLUTION };
	LUNAScaleMode scaleMode = LUNAScaleMode::STRETCH_BY_WIDTH;
	int contentWidth = 480;
	int contentHeight = 320;
	bool debug_missedStrings = false;

private:
	json11::Json customValues;

private:
	void ReadScreenOrientation(const json11::Json& jsonConfig);
	void ReadResolutions(const json11::Json& jsonConfig);
	void ReadScaleMode(const json11::Json& jsonConfig);
	void ReadContentWidth(const json11::Json& jsonConfig);
	void ReadContentHeight(const json11::Json& jsonConfig);
	void ReadDebugValues(const json11::Json& jsonConfig);

public:
	const json11::Json& GetCustomValues() const;
	bool Read();
};

}
